<template>
	<view>
		<view class="">
			<u-cell-group>
				<view class="set1" v-for="(item,index) in account" :key="index" @click="accut(item.titile)">
					<u-cell :value="item.value" :title="item.titile" isLink></u-cell>
				</view>
			</u-cell-group>
		</view>
		<myModal v-if='show' contents="确定要注销账号？" @confirm="confirm" @cancel='cancel'></myModal>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from "vuex"
	export default {
		data() {
			return {
				account: [{
						value: '',
						titile: "淘宝账号"
					},
					{
						value: '156******12',
						titile: "手机号"
					},
					{
						value: '',
						titile: "修改登录密码"
					},
					{
						value: '未开启',
						titile: "指纹登录"
					},
					{
						value: '查看当前在线得设备',
						titile: "登录设备管理"
					},
					{
						value: '账号日志',
						titile: "查看近期敏感操作"
					},
					{
						value: '',
						titile: "注销账号"
					},
				],
				show: false,
			};
		},
		computed: {
			...mapState('setting', ["settingAccount"]),
			...mapState("login", ["userinfo"]),
		},
		onShow() {
			//隐藏一部分
uni.$setNavigationBarColor()
			let a = this.userinfo.phone.substr(0, 3)
			let b = this.userinfo.phone.substr(this.userinfo.phone.length - 2, this.userinfo.phone.length)
			let c = '******'
			//是否开启指纹
			wx.checkIsSoterEnrolledInDevice({
				checkAuthMode: 'fingerPrint',
				success: (res) => {
					if (res.isEnrolled) {
						this.account[3].value = '已开启'
					} else {
						this.account[3].value = '未开启'
					}
				}
			})
			this.account[0].value = this.settingAccount
			this.account[1].value = a + c + b

		},
		methods: {
			...mapMutations("login", ["deleteAccountNumber", 'deleteTokenToStorage']),
			accut(titile) {
				switch (titile) {
					case '淘宝账号':
						uni.navigateTo({
							url: "/subAbility/modifyAccount/modifyAccount?titile=" + '淘宝账号'
						})
						break;
					case '手机号':
						uni.navigateTo({
							url: "/subAbility/modifyAccount/modifyAccount?titile=" + '手机号'
						})
						break;
					case '修改登录密码':
						uni.navigateTo({
							url: "/subAbility/modifyAccount/modifyAccount?titile=" + '修改登录密码'
						})
						break;
					case '登录设备管理':
						uni.navigateTo({
							url: "/subAbility/equipment/equipment"
						})
						break;
					case '指纹登录':
						uni.navigateTo({
							url: "/subAbility/fingerprint/fingerprint"
						})
						break;
					case '查看近期敏感操作':
						uni.navigateTo({
							url: "/subStting/my-news/my-news"
						})
						break;
					case '注销账号':
						this.show = true
						break;
					default:

				}

			},
			//删除账号
			confirm() {
				let user = void 0

				if (this.userinfo.nickName == "小懒") {
					user = 'admin'
				}else{
					user = this.userinfo.nickName
				}

				this.deleteAccountNumber(user)
				this.deleteTokenToStorage()
				uni.switchTab({
					url: "/pages/my/my"
				})

				this.cancel()
			},
			cancel() {
				this.show = false
			},
		}
	}
</script>

<style lang="scss">
	.set1 {
		padding-bottom: 20px;
	}
</style>